import React, { Component } from 'react';
import { Image, ScrollView, StyleSheet, Text, Dimensions, TouchableOpacity,Alert ,StatusBar} from 'react-native';



// import {CachedImage} from "react-native-img-cache";


import Common  from '../common/constants';
import Header from '../components/Header';
import NewsContainer from '../containers/NewsContainer';


// import Orientation from 'react-native-orientation';
let image1 = require('../images/bg.png');

export default class StartPage extends Component {
    
    constructor() {
        super();
        this.state = {
              flashs:[],
              imgsize:1
          };

    };

    componentWillUpdate(){
        clearTimeout(this.timer);
    }



    componentDidMount() 
    {
         // Orientation.lockToPortrait();
        // this.getsplash();
             this.props.navigator.push({
                component:NewsContainer,
                passProps:{
                    title:"333"
                },
                
             });
        this.timer = setTimeout(() => 
        {
             this.setState({flashs:[]});
        }, 
        1000);
    }


    componentWillUnmount(){
        // this.unsubscribe(); 
        this.timer && clearTimeout(this.timer);
        this.setState = (state,callback)=>{return;};  //Can only update a mounted or mounting component 这个问题，原因是当离开页面以后，组件已经被卸载，执行setState时无法找到渲染组件
    }



    
    render() {

        let contentContainerStyle={width: Common.window.width * (this.state.imgsize),
                                    height: Common.window.height};

        // console.log('CachedImage');
        console.log('this.state.flashs:',this.state.flashs);

        return (
            <ScrollView
                contentContainerStyle={contentContainerStyle}
                bounces={false}
                pagingEnabled={true}
                horizontal={true}>
                <StatusBar animated={true} hidden={true} backgroundColor={'blue'} translucent={true}
                            barStyle={'default'} showHideTransition={'fade'}
                    networkActivityIndicatorVisible={true}
                />
                <Text>start page</Text>
                
            </ScrollView>);

    }
}



const styles = StyleSheet.create({
    contentContainer: {
        width: Common.window.width * 4,
        height: Common.window.height,
    },
    backgroundImage: {
        width: Common.window.width,
        height: Common.window.height,
        resizeMode:'stretch'
    },
    btnOut:{
        alignItems:'center',
    },
    btn:{
        width:150,
        height:50,
        backgroundColor:'#90ee90',
        borderRadius:8,
        justifyContent:'center',
        alignItems:'center',
        marginTop:Common.window.height-60,

    },
    btnText:{
        fontSize:18,
        color:'#fff'
    },
});
